//
//  NSDate+SeasonByHemisphere.m
//  WeatherApp
//
//  Created by Yuliya Grasevych on 29.07.14.
//  Copyright (c) 2014 Yuliya Grasevych. All rights reserved.
//

#import "NSDate+SeasonByHemisphere.h"

@implementation NSDate (SeasonByHemisphere)

+(WASeason)seasonByHemisphere:(WAHemisphere)hemisphere
{
    NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitMonth fromDate:[NSDate date]];
    NSInteger month = [components month];
    WASeason season = WAWinterSeason;
    switch (month) {
        case 1:
        case 2:
        case 12:
            season = (hemisphere == WANorthernHemisphere) ?: WASummerSeason;
            break;
            
        case 3:
        case 4:
        case 5:
            season = (hemisphere == WANorthernHemisphere) ? WASpringSeason : WAAutumnSeason;
            break;
            
        case 6:
        case 7:
        case 8:
            season = (hemisphere == WANorthernHemisphere) ? WASummerSeason : WAWinterSeason;
            break;
            
        case 9:
        case 10:
        case 11:
            season = (hemisphere == WANorthernHemisphere) ? WAAutumnSeason : WASpringSeason;
            break;
            
        default:
            break;
    }
    return season;
}

+(NSString *)seasonStringRespesentation:(WASeason)season
{
    NSString *seasonString = @"";
    switch (season) {
        case WASpringSeason:
            seasonString = @"spring";
            break;
        case WASummerSeason:
            seasonString = @"summer";
            break;
        case WAAutumnSeason:
            seasonString = @"autumn";
            break;
        case WAWinterSeason:
            seasonString = @"winter";
            break;
        default:
            break;
    }
    return seasonString;
}
@end
